/*
*********************************************************************************************************
*                                              EXAMPLE CODE
*
*                          (c) Copyright 2003-2013; Micrium, Inc.; Weston, FL
*
*               All rights reserved.  Protected by international copyright laws.
*               Knowledge of the source code may NOT be used to develop a similar product.
*               Please help us continue to provide the Embedded community with the finest
*               software available.  Your honesty is greatly appreciated.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                       uC/OS-III Application Code
*                                                Template
*
* The template application code provided here can be used as a foundation for your own uC/OS-III-based
* projects.  This file, app_cfg.h, is normally where an application's task priorities and stack sizes
* are defined.
*
* Filename      : app_cfg.h
* Version       : V1.00
*********************************************************************************************************
*/

#ifndef  __BUTTON_H_
#define  __BUTTON_H__


/*
*********************************************************************************************************
*                                            PRIVATE TYPEDEF
*********************************************************************************************************
*/
#define KEY_NUM   4

typedef enum
{
  KEY_PRESS    = 0,
  KEY_NO_PRESS = 1
}KEY_STATE;

typedef enum
{
  FLAG_NULL  = 0,
  FLAG_YES   = 1,
  FLAG_NO    = 2
}FLAG_YN;

typedef struct 
{  
  FLAG_YN   key_press         [KEY_NUM];
  uint8_t   key_press_time    [KEY_NUM];
  uint8_t   key_no_press_time [KEY_NUM];
  FLAG_YN   key_long_press    [KEY_NUM];
  KEY_STATE key_value         [KEY_NUM];
  FLAG_YN   key_execute_flag  [KEY_NUM]; 
}KEY_TAB;

typedef struct
{
  FLAG_YN  KEY_1_PRESS;
  FLAG_YN  KEY_2_PRESS;
  FLAG_YN  KEY_3_PRESS;
}KEY_PRESS_STATE;

#define BUTTON_1_INDEX        1
#define BUTTON_2_INDEX        2
#define BUTTON_3_INDEX        3

#define KEY_SHORT_PRESS       30
#define KEY_LONG_PRESS        100
#define KEY_HOLD_TIME         200

#define KEY_NO_PRESS_CNT      100

extern KEY_TAB key;
extern KEY_PRESS_STATE key_state;


extern void Button_Init(KEY_TAB *key);
extern void Serve_Button (void);

#endif   //BUTTON_H